ggplot2Note: There are often multiple ways to answer each question.
Load the ggplot2 and fueleconomy packages, as well as the vehicles dataset.
Make a scatterplot of hwy vs. cty.
Convert the cyl column to a factor.
Modify the plot from Qn 1 such that the color of the dot represents cyl value. Also, change the color scale to “YlOrRd”.
There is a lot of overplotting in the plot above. Remove the color scale and modify the previous plot so that alpha = 0.1.
Make a histogram of year.
Make a histogram of year with just 5 bins.
For each value of cyl, make a violin plot of hwy values.
For each value of cyl, make a boxplot of hwy values.
Make a barplot to show how many cars of each type of fuel there are in the dataset. (Hint: Use the geom_bar geom.)
Add a coord_flip() layer to the previous plot to make a horizontal barplot.